{% extends 'public/layout.html' %}

{% block load_css %}
    <link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="/static/css/plugins/iCheck/custom.css" rel="stylesheet">
{% endblock %}

{% block mbx %}
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-sm-10">
            <h2></h2>
            <ol class="breadcrumb">
                <li>
                    <a href="{% url 'index' %}">仪表盘</a>
                </li>

                <li>
                    <a>监控中心</a>
                </li>


                <li class="active">
                    <strong>监控图表</strong>
                </li>

            </ol>
        </div>
        <div class="col-sm-2">
        </div>
    </div>
{% endblock %}

{% block body %}

<div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <form id="asset_form">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>图表展示</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>


                    <div class="ibox-content" style="overflow:scroll;white-space : nowrap">

                            <input name="id" value="{{id}}" type="hidden">

                            <div class="form-group"><label class="col-md-2 control-label">{{hostname}}图表监控</label>
                                <div class="col-md-9">
                                    <select class="select2_demo_1 form-control" name="slice" id="slice" onchange="change_info()">
                                        {% for type_tuple in time_slice %}
                                            {% if type_tuple.0 == sl  %}
                                                <option value="{{ type_tuple.0 }}" selected="selected"> {{ type_tuple.1 }}</option>
                                            {% else %}
                                                <option value="{{ type_tuple.0 }}"> {{ type_tuple.1 }}</option>
                                            {% endif %}
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>
                    </br>
                    <div class="hr-line-dashed"></div>

                    <style type="text/css">
                    .link{float: left;}
                    .openfile{float: left;}
                    .opentable{float: left;}
                    .qps{float: left;}
                    .tps{float: left;}
                    .connects{float: left;}
                    .flow{float: left;}
                    .innodb_io{float: left;}
                    .key_buffer{float: left;}
                    </style>
                    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
                    <div class="link" id="link" style="width:33%;height:350px;"></div>
                    <div class="openfile" id="openfile" style="width:33%;height:350px;"></div>
                    <div class="opentable" id="opentable" style="width:34%;height:350px;"></div>

                    <div class="qps" id="qps" style="width:50%;height:300px;"></div>
                    <div class="tps" id="tps" style="width:50%;height:300px;"></div>

                    <div class="connects" id="connects" style="width:50%;height:300px;"></div>
                    <div class="flow" id="flow" style="width:50%;height:300px;"></div>
                    <div class="innodb_io" id="innodb_io" style="width:50%;height:300px;"></div>
                    <div class="key_buffer" id="key_buffer" style="width:50%;height:300px;"></div>



                    <script src="https://cdn.bootcss.com/echarts/4.1.0.rc2/echarts-en.common.js"></script>
                    <!--<script src="/static/js/echarts.min.js"></script>-->


                    <script type="text/javascript">
                        // 基于准备好的dom，初始化echarts实例
                        var link = echarts.init(document.getElementById('link'));

                        // 指定图表的配置项和数据
                        var option = {
                            title: {
                                text: '连接池',
                                left: 'left',
                                textStyle: {
                                   fontSize:14,
                                },
                            },
                            color:['red','green'],
                            tooltip: {
                                trigger: 'item',
                                formatter: '{a} </br>{b} : {c} ({d}%)'
                            },
                            legend: {
                                orient: 'horizontal',
                                right: "20%",
                                height: "auto",
                                itemWidth: 15,             // 图例图形宽度
                                itemHeight: 15,            // 图例图形高度
                                data: ["已用连接", "可用连接"]
                            },
                            xAxis: {
                                data: ["已用连接", "可用连接"],
                                type: 'category',
                                axisLabel: {
                                    interval: 0
                                },
                                "show":false
                            },
                            yAxis: {
                                "show":false,
                            },
                            grid: {
                                top: '120%',
                                left: '3%',
                                right: '4%',
                                bottom: '12%',
                                containLabel: true
                            },
                            series: [{
                                name: '连接数',
                                type: 'pie',
                                //radius: ['50%','60%'],
                                data: [
                                        {value:{{ s_Threads_connected|safe }}, name: '已用连接'},
                                        { value:{{ s_open_files_limit|safe }}, name: '可用连接'}
                                       ]

                            }]
                        }

                        // 使用刚指定的配置项和数据显示图表。
                        link.setOption(option);
                    </script>

                    <script type="text/javascript">
                        // 基于准备好的dom，初始化echarts实例
                        var openfile = echarts.init(document.getElementById('openfile'));

                        // 指定图表的配置项和数据
                        var option = {
                            title: {
                                text: '打开文件数',
                                left: 'left',
                                textStyle: {
                                   fontSize:14,
                                },
                            },
                            color:['Purple','Orange'],
                            legend: {
                                orient: 'horizontal',
                                right: "3%",
                                itemWidth: 15,             // 图例图形宽度
                                itemHeight: 15,            // 图例图形高度
                                data: ["已打开文件数", "可用文件句柄"]
                            },
                            tooltip: {
                                trigger: 'item',
                                formatter: '{a} </br>{b} : {c} ({d}%)'
                            },

                            xAxis: {
                                data: ["已打开文件数", "可用文件句柄"],
                                type: 'category',
                                axisLabel: {
                                    interval: 0
                                },
                                "show":false
                            },
                            yAxis: {
                                "show":false,
                            },

                            series: [{
                                name: '打开文件数',
                                type: 'pie',
                                //radius: ['50%','60%'],
                                data: [
                                        {value:{{ open_files }},name: '已打开文件数'},
                                        {value:{{ open_files_limit }},name: '可用文件句柄'}
                                       ]

                            }]
                        };

                        // 使用刚指定的配置项和数据显示图表。
                        openfile.setOption(option);
                    </script>

                    <script type="text/javascript">
                        // 基于准备好的dom，初始化echarts实例
                        var opentable = echarts.init(document.getElementById('opentable'));

                        // 指定图表的配置项和数据
                        var option = {
                            title: {
                                text: '表缓存数',
                                left: 'left',
                                textStyle: {
                                   fontSize:14,
                                },
                            },

                            tooltip: {
                                trigger: 'item',
                                formatter: '{a} </br>{b} : {c} ({d}%)'
                            },
                            legend: {
                                orient: 'horizontal',
                                right: "20%",
                                itemWidth: 15,             // 图例图形宽度
                                itemHeight: 15,            // 图例图形高度
                                data: ["当前打开表数", "可用表缓存"]
                            },
                            xAxis: {
                                data: ["当前打开表数", "可用表缓存"],
                                type: 'category',
                                axisLabel: {
                                    interval: 0
                                },
                                "show":false
                            },
                            yAxis: {
                                "show":false,
                            },

                            series: [{
                                name: '表缓存数',
                                type: 'pie',
                                //radius: ['50%','60%'],
                                data: [
                                        {value:{{ open_tables }},name: '当前打开表数'},
                                        {value:{{ table_open_cache }},name: '可用表缓存'}
                                       ],
                                itemStyle: {
                                    normal: {
                                        color: function(params) {

                                            var colorList = [

                                               '#008B8B','#FFB6C1'];
                                                return colorList[params.dataIndex]
                                        },
                                        label: {
                                            show: true
                                        }
                                        }

                                    },
                            }]
                        };

                        // 使用刚指定的配置项和数据显示图表。
                        opentable.setOption(option);
                    </script>

                    <script type="text/javascript">
                        // 基于准备好的dom，初始化echarts实例
                        var insert_qps = {{insert_qps_list|safe}};
                        var update_qps = {{update_qps_list|safe}};
                        var select_qps = {{select_qps_list|safe}};
                        var delete_qps = {{delete_qps_list|safe}};
                        var myChart_qps = echarts.init(document.getElementById("qps"));
                        var data_insert_qps = [];
                        var data_update_qps= [];
                        var data_delete_qps = [];
                        var data_select_qps = [];

                        insert_qps.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_insert_qps.push(obj);
                        })
                        update_qps.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_update_qps.push(obj);
                        })
                        select_qps.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_select_qps.push(obj);
                        })
                        delete_qps.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_delete_qps.push(obj);
                        })

                        //window.alert(data);
                        // 指定图表的配置项和数据
                        var option = {
                            title: {
                                text: "增删改查QPS"
                            },
                            tooltip: {
                                trigger: 'axis',
                                axisPointer: {
                                    type: 'cross',
                                    label: {
                                        backgroundColor: '#6a7985'
                                    }
                                }
                            },
                            xAxis: {
                                type: 'time',
                                splitLine: {
                                    show: false
                                }
                            },
                            yAxis: {
                                type: 'value',
                                boundaryGap: [0, '100%'],
                                splitLine: {
                                    show: false
                                }
                            },
                            series: [{
                                        name: "insert_qps",
                                        type: 'line',
                                        showSymbol:false,
                                        color:['#CD5C5C'],
                                        data: data_insert_qps,
                                        areaStyle: {
                                            normal: {
                                                color: {
                                                    type: 'linear',//设置线性渐变
                                                    x: 0,
                                                    y: 0,
                                                    x2: 0,
                                                    y2: 1,
                                                    colorStops: [{
                                                        offset: 0, color: "IndianRed" // 0% 处的颜色
                                                    }, {
                                                        offset: 1, color: 'white' // 100% 处的颜色
                                                    }],
                                                    globalCoord: false // 缺省为 false
                                                },
                                            }
                                        },
                                        lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },

                                    },
                                    {
                                        name: "update_qps",
                                        type: 'line',
                                        showSymbol:false,
                                        color:['#BC8F8F'],
                                        data: data_update_qps,
                                        lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                        areaStyle: {
                                            normal: {
                                                color: {
                                                    type: 'linear',//设置线性渐变
                                                    x: 0,
                                                    y: 0,
                                                    x2: 0,
                                                    y2: 1,
                                                    colorStops: [{
                                                        offset: 0, color: "RosyBrown" // 0% 处的颜色
                                                    }, {
                                                        offset: 1, color: 'white' // 100% 处的颜色
                                                    }],
                                                    globalCoord: false // 缺省为 false
                                                },
                                            }
                                        },
                                    },
                                    {
                                        name: "delete_qps",
                                        type: 'line',
                                        showSymbol:false,
                                        color:['#00FF00'],
                                        data: data_delete_qps,
                                        lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                        areaStyle: {
                                            normal: {
                                                color: {
                                                    type: 'linear',//设置线性渐变
                                                    x: 0,
                                                    y: 0,
                                                    x2: 0,
                                                    y2: 1,
                                                    colorStops: [{
                                                        offset: 0, color: "Green" // 0% 处的颜色
                                                    }, {
                                                        offset: 1, color: 'white' // 100% 处的颜色
                                                    }],
                                                    globalCoord: false // 缺省为 false
                                                },
                                            }
                                        },
                                    },
                                    {
                                        name: "select_qps",
                                        type: 'line',
                                        showSymbol:false,
                                        color:['#FFA500'],
                                        data: data_select_qps,
                                        lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                        areaStyle: {
                                            normal: {
                                                color: {
                                                    type: 'linear',//设置线性渐变
                                                    x: 0,
                                                    y: 0,
                                                    x2: 0,
                                                    y2: 1,
                                                    colorStops: [{
                                                        offset: 0, color: "Orange" // 0% 处的颜色
                                                    }, {
                                                        offset: 1, color: 'white' // 100% 处的颜色
                                                    }],
                                                    globalCoord: false // 缺省为 false
                                                },
                                            }
                                        },
                                    }],
                            };
                        // 使用刚指定的配置项和数据显示图表。
                        myChart_qps.setOption(option);
                    </script>

                    <script type="text/javascript">
                        // 基于准备好的dom，初始化echarts实例
                        var res_commit = {{commit_tps_list|safe}};
                        var res_rollback = {{rollback_tps_list|safe}};
                        //window.alert(res);
                        var myChart_commit = echarts.init(document.getElementById("tps"));
                        var data_commit = [];
                        var data_rollback = [];

                        res_commit.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_commit.push(obj);
                        })
                        res_rollback.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_rollback.push(obj);
                        })

                        //window.alert(data);
                        // 指定图表的配置项和数据
                        var option = {
                            title: {
                                text: "TPS"
                            },
                            tooltip: {
                                trigger: 'axis',
                                axisPointer: {
                                    type: 'cross',
                                    label: {
                                        backgroundColor: 'rgba(255, 255, 255, .5)'
                                    },
                                    crossStyle: {//线的颜色 axisPointer.type 为 'cross' 时有效。
                                        color: '#fff'
                                    }
                                }
                            },
                            //backgroundColor : 'rgba(43, 62, 75, .5)',//背景颜色
                            toolbox: {//工具栏
                                show: false//是否显示工具栏组件
                            },
                            xAxis: {
                                type: 'time',
                                splitLine: {
                                    show: false
                                }
                            },
                            yAxis: {
                                type: 'value',
                                boundaryGap: [0, '100%'],
                                splitLine: {
                                    show: false
                                }
                            },
                            series: [{
                                name: "commit_tps",
                                type: 'line',
                                showSymbol:false,
                                color:['#ff907f'],
                                data: data_commit,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "red" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            },
                            {
                                name: "rollback_tps",
                                type: 'line',
                                showSymbol:false,
                                color:['#006400'],
                                data: data_rollback,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "DarkGreen" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            }],
                        };

                        // 使用刚指定的配置项和数据显示图表。
                        myChart_commit.setOption(option);
                    </script>

                    <script type="text/javascript">
                        // 基于准备好的dom，初始化echarts实例
                        var res_threads_running = {{threads_running_list|safe}};
                        var res_threads_cached = {{threads_cached_list|safe}};
                        var res_threads_connected = {{threads_connected_list|safe}};
                        var res_threads_created = {{threads_created_list|safe}};
                        //window.alert(res);
                        var threads = echarts.init(document.getElementById("connects"));
                        var data_threads_running = [];
                        var data_threads_cached = [];
                        var data_threads_connected = [];
                        var data_threads_created = [];

                        res_threads_created.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_threads_created.push(obj);
                        })
                        res_threads_running.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_threads_running.push(obj);
                        })
                        res_threads_cached.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_threads_cached.push(obj);
                        })

                        res_threads_connected.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_threads_connected.push(obj);
                        })

                        //window.alert(data);
                        // 指定图表的配置项和数据
                        var option = {
                            title: {
                                text: "连接数"
                            },
                            tooltip: {
                                trigger: 'axis',
                                axisPointer: {
                                    type: 'cross',
                                    label: {
                                        backgroundColor: 'rgba(255, 255, 255, .5)'
                                    },
                                    crossStyle: {//线的颜色 axisPointer.type 为 'cross' 时有效。
                                        color: '#fff'
                                    }
                                }
                            },
                            //backgroundColor : 'rgba(43, 62, 75, .5)',//背景颜色
                            toolbox: {//工具栏
                                show: false//是否显示工具栏组件
                            },
                            xAxis: {
                                type: 'time',
                                splitLine: {
                                    show: false
                                }
                            },
                            yAxis: {
                                type: 'value',
                                boundaryGap: [0, '100%'],
                                splitLine: {
                                    show: false
                                }
                            },
                            series: [{
                                name: "threads_running",
                                type: 'line',
                                showSymbol:false,
                                color:['#B22222'],
                                data: data_threads_running,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "Firebrick" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            },
                            {
                                name: "threads_cached",
                                type: 'line',
                                showSymbol:false,
                                color:['#006400'],
                                data: data_threads_cached,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "DarkGreen" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            },
                            {
                                name: "threads_connected",
                                type: 'line',
                                showSymbol:false,
                                color:['#FFE4B5'],
                                data: data_threads_connected,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "Moccasin" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            },
                            {
                                name: "threads_created",
                                type: 'line',
                                showSymbol:false,
                                color:['#FCFCFC'],
                                data: data_threads_created,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "DarkSlateGray" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            }],
                        };

                        // 使用刚指定的配置项和数据显示图表。
                        threads.setOption(option);
                    </script>

                    <script type="text/javascript">
                        // 基于准备好的dom，初始化echarts实例
                        var res_bytes_sent = {{bytes_sent_list|safe}};
                        var res_bytes_received = {{bytes_received_list|safe}};
                        //window.alert(res);
                        var myChart_flow = echarts.init(document.getElementById("flow"));
                        var data_bytes_sent = [];
                        var data_bytes_received = [];

                        res_bytes_sent.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_bytes_sent.push(obj);
                        })
                        res_bytes_received.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_bytes_received.push(obj);
                        })

                        //window.alert(data);
                        // 指定图表的配置项和数据
                        var option = {
                            title: {
                                text: "流量(K)"
                            },
                            tooltip: {
                                trigger: 'axis',
                                axisPointer: {
                                    type: 'cross',
                                    label: {
                                        backgroundColor: 'rgba(255, 255, 255, .5)'
                                    },
                                    crossStyle: {//线的颜色 axisPointer.type 为 'cross' 时有效。
                                        color: '#fff'
                                    }
                                }
                            },
                            //backgroundColor : 'rgba(43, 62, 75, .5)',//背景颜色
                            toolbox: {//工具栏
                                show: false//是否显示工具栏组件
                            },
                            xAxis: {
                                type: 'time',
                                splitLine: {
                                    show: false
                                }
                            },
                            yAxis: {
                                type: 'value',
                                boundaryGap: [0, '100%'],
                                splitLine: {
                                    show: false
                                }
                            },
                            series: [{
                                name: "IN 流量",
                                type: 'line',
                                showSymbol:false,
                                color:['#ff907f'],
                                data: data_bytes_sent,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "red" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            },
                            {
                                name: "OUT流量",
                                type: 'line',
                                showSymbol:false,
                                color:['#006400'],
                                data: data_bytes_received,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "DarkGreen" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            }],
                        };

                        // 使用刚指定的配置项和数据显示图表。
                        myChart_flow.setOption(option);
                    </script>

                    <script type="text/javascript">
                        // 基于准备好的dom，初始化echarts实例
                        var res_innodb_buffer_pool_reads = {{innodb_buffer_pool_reads_list|safe}};
                        var res_Innodb_buffer_pool_pages_flushed = {{Innodb_buffer_pool_pages_flushed_list|safe}};
                        //window.alert(res);
                        var myChart_innodb_io = echarts.init(document.getElementById("innodb_io"));
                        var data_innodb_buffer_pool_reads = [];
                        var data_Innodb_buffer_pool_pages_flushed = [];

                        res_innodb_buffer_pool_reads.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_innodb_buffer_pool_reads.push(obj);
                        })
                        res_Innodb_buffer_pool_pages_flushed.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_Innodb_buffer_pool_pages_flushed.push(obj);
                        })

                        //window.alert(data);
                        // 指定图表的配置项和数据
                        var option = {
                            title: {
                                text: "Innodb IO"
                            },
                            tooltip: {
                                trigger: 'axis',
                                axisPointer: {
                                    type: 'cross',
                                    label: {
                                        backgroundColor: 'rgba(255, 255, 255, .5)'
                                    },
                                    crossStyle: {//线的颜色 axisPointer.type 为 'cross' 时有效。
                                        color: '#fff'
                                    }
                                }
                            },
                            //backgroundColor : 'rgba(43, 62, 75, .5)',//背景颜色
                            toolbox: {//工具栏
                                show: false//是否显示工具栏组件
                            },
                            xAxis: {
                                type: 'time',
                                splitLine: {
                                    show: false
                                }
                            },
                            yAxis: {
                                type: 'value',
                                boundaryGap: [0, '100%'],
                                splitLine: {
                                    show: false
                                }
                            },
                            series: [{
                                name: "从磁盘请求数",
                                type: 'line',
                                showSymbol:false,
                                color:['#FFA500'],
                                data: data_innodb_buffer_pool_reads,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "Orange" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            },
                            {
                                name: "刷新脏页请求数",
                                type: 'line',
                                showSymbol:false,
                                color:['#006400'],
                                data: data_Innodb_buffer_pool_pages_flushed,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "DarkGreen" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            }],
                        };

                        // 使用刚指定的配置项和数据显示图表。
                        myChart_innodb_io.setOption(option);
                    </script>

                    <script type="text/javascript">
                        // 基于准备好的dom，初始化echarts实例
                        var keybuffer = echarts.init(document.getElementById("key_buffer"));

                        var res_key_buffer_read_rate = {{key_buffer_read_rate_list|safe}};
                        var res_key_buffer_write_rate = {{key_buffer_write_rate_list|safe}};
                        var res_key_blocks_used_rate = {{key_blocks_used_rate_list|safe}};

                        var data_key_buffer_read_rate = [];
                        var data_key_buffer_write_rate = [];
                        var data_key_blocks_used_rate = [];

                        res_key_buffer_read_rate.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_key_buffer_read_rate.push(obj);
                        })
                        res_key_buffer_write_rate.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_key_buffer_write_rate.push(obj);
                        })
                        res_key_blocks_used_rate.forEach((item)=>{
                            var date = new Date(item.timeline * 1000);
                            var YY = date.getFullYear() + '-';
                            var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                            var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                            var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                            var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                            var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                            var formatedTime = YY + MM + DD +" "+hh + mm + ss;
                            //var formatedTime = [time.getFullYear(), (time.getMonth()+1 < 10 ? '0'+(time.getMonth()+1) : time.getMonth()+1), time.getDate()].join('-')+' '+[time.getHours(),time.getMinutes(),time.getSeconds()+'0'].join(':');
                            //window.alert(formatedTime);
                            var obj = {name:formatedTime,value: [formatedTime,item.value]};
                            data_key_blocks_used_rate.push(obj);
                        })
                        //window.alert(data);
                        // 指定图表的配置项和数据
                        var option = {
                            title: {
                                text: "Key Buffer"
                            },
                            tooltip: {
                                trigger: 'axis',
                                axisPointer: {
                                    type: 'cross',
                                    label: {
                                        backgroundColor: 'rgba(255, 255, 255, .5)'
                                    },
                                    crossStyle: {//线的颜色 axisPointer.type 为 'cross' 时有效。
                                        color: '#fff'
                                    }
                                }
                            },
                            //backgroundColor : 'rgba(43, 62, 75, .5)',//背景颜色
                            toolbox: {//工具栏
                                show: false//是否显示工具栏组件
                            },
                            xAxis: {
                                type: 'time',
                                splitLine: {
                                    show: false
                                }
                            },
                            yAxis: {
                                type: 'value',
                                boundaryGap: [0, '100%'],
                                splitLine: {
                                    show: false
                                }
                            },
                            series: [{
                                name: "key读请求命中率",
                                type: 'line',
                                showSymbol:false,
                                color:['#FFA500'],
                                data: data_key_buffer_read_rate,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "Orange" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            },
                            {
                                name: "key写请求命中率",
                                type: 'line',
                                showSymbol:false,
                                color:['#D8BFD8'],
                                data: data_key_buffer_write_rate,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "Thistle" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            },
                            {
                                name: "key块使用率",
                                type: 'line',
                                showSymbol:false,
                                color:['#483D8B'],
                                data: data_key_blocks_used_rate,
                                lineStyle: {
                                            normal: {
                                                    width:0.5//设置线条粗细
                                            }
                                        },
                                areaStyle: {
                                    normal: {
                                        color: {
                                            type: 'linear',//设置线性渐变
                                            x: 0,
                                            y: 0,
                                            x2: 0,
                                            y2: 1,
                                            colorStops: [{
                                                offset: 0, color: "DarkSlateBlue" // 0% 处的颜色
                                            }, {
                                                offset: 1, color: 'white' // 100% 处的颜色
                                            }],
                                            globalCoord: false // 缺省为 false
                                        },
                                    }
                                },
                            }],
                        };

                        // 使用刚指定的配置项和数据显示图表。
                        keybuffer.setOption(option);
                    </script>

                </div>
                </div>
            </div>
            </form>
        </div>
    </div>
{% endblock %}

{% block load_js %}
    <script src="/static/js/plugins/flot/jquery.flot.js"></script>
    <script src="/static/js/plugins/flot/jquery.flot.tooltip.min.js"></script>
    <script src="/static/js/plugins/flot/jquery.flot.resize.js"></script>

    <script>
        $(document).ready(function () {
            var d1 = [[1262304000000, 6], [1264982400000, 3057], [1267401600000, 20434], [1270080000000, 31982], [1272672000000,
                26602], [1275350400000, 27826], [1277942400000, 24302], [1280620800000, 24237], [1283299200000, 21004],
                [1285891200000, 12144], [1288569600000, 10577], [1291161600000, 10295]];
            var d2 = [[1262304000000, 5], [1264982400000, 200], [1267401600000, 1605], [1270080000000, 6129], [1272672000000,
                11643], [1275350400000, 19055], [1277942400000, 30062], [1280620800000, 39197], [1283299200000, 37000],
                [1285891200000, 27000], [1288569600000, 21000], [1291161600000, 17000]];

            var data1 = [
                {label: "Data 1", data: d1, color: '#17a084'},
                {label: "Data 2", data: d2, color: '#127e68'}
            ];
            $.plot($("#flot-chart1"), data1, {
                xaxis: {
                    tickDecimals: 0
                },
                series: {
                    lines: {
                        show: true,
                        fill: true,
                        fillColor: {
                            colors: [{
                                opacity: 1
                            }, {
                                opacity: 1
                            }]
                        }
                    },
                    points: {
                        width: 0.1,
                        show: false
                    }
                },
                grid: {
                    show: false,
                    borderWidth: 0
                },
                legend: {
                    show: false
                }
            })
        });

    function timeslice(value) {
            var slice = value.options[value.selectedIndex].value;
                if (slice == ""){
                    return false;
                }
                //window.alert(slice);
                var url = "{% url 'chart_detail' %}?id={{id}}&slice={0}".format(slice);
                this.location.href=url;
            };

    function change_info(){
        var args = $("#asset_form").serialize();
        window.location = "{% url 'mysql_detail' %}?" + args
    }

    </script>



{% endblock %}